package
{
	import flash.media.Camera;
	import flash.media.Microphone;
	
	import models.LocalSetting;
	import models.vo.UserVO;
	
	import org.dexter.sendDexterEvent;
	
	public class GLocalSetting extends LocalSetting
	{
		public function GLocalSetting()
		{
			super();
		}
		public function set userSex(v:int):void{
			setValue("userSex",v);
		}
		public function get userSex():int{
			return so.data["userSex"];
		}
		[DexterEvent]
		public function $getDeviceConfig(groupAddress:String = null):Object{
			var o:Object = {cams:Camera.names,mics:Microphone.names,cam:camera,mic:microphone,camSetting:cameraSetting};
			if(groupAddress)sendDexterEvent("sendToUser",groupAddress,"callJs","setDeviceConfigDialog",o);
			return o;
		}
		[DexterEvent][DexterExternal]
		public function $setDeviceConfig(setting:Object,userId:String):void{
			var user:UserVO = sendDexterEvent("getUserByID",userId);
			if(!user) return;
			if(!user.isSelf)sendDexterEvent("sendToUser",user,"setDeviceConfig",setting);
			else{
				if(setting.camera!=null)camera = setting.camera;
				if(setting.cameraSetting)cameraSetting = setting.cameraSetting;
				if(setting.microphone!=null)microphone = setting.microphone;
				sendDexterEvent("changeDevice");
			}
		}
	}
}